﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for PermissionDAL
/// </summary>
public class PermissionDAL:IPermissionDAL
{
	public PermissionDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    /// <summary>
    /// Load all permission
    /// </summary>
    /// <returns></returns>
    public List<Permission> LoadPermission()
    {
        string strSQL = "SELECT PermissionID,Name FROM Permission";
        SqlDataReader reader;
        List<Permission> list = new List<Permission>();
        Permission per = null;
        try
        {
            reader = SqlHelper.ExecuteReader(CommandType.Text, strSQL);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    per = new Permission();
                    per.PermissionID = reader["PermissionID"].ToString();
                    per.Name = reader["Name"].ToString();
                    list.Add(per);
                }
            }
            return list;
        }
        catch (Exception)
        {
            throw;
        }
    }
}